/*
Copyright 2014, KISSY v1.47
MIT Licensed
build time: May 22 12:15
*/
KISSY.add("base",["attribute"],function(e,q){function h(b,a){return function(d){return function(){a?d.apply(this,arguments):this.callSuper.apply(this,arguments);var c=arguments.callee.__owner__.__extensions__||[];a&&c.reverse();var f=arguments,e;if(e=c&&c.length)for(var g=0;g<e;g++){var m=c[g]&&(!b?c[g]:c[g].prototype[b]);m&&m.apply(this,f||[])}a?this.callSuper.apply(this,arguments):d.apply(this,arguments)}}}function n(b){var a=this.__hooks__,d=this.prototype;if(this.__extensions__.length&&a)for(var c in a)if(!d.hasOwnProperty(c)||
b.hasOwnProperty(c))b[c]=b[c]||o;return r.call(this,b)}function s(b){var a;b.target===this&&(a=this[i+b.type.slice(5).slice(0,-6)],a.call(this,b.newVal,b))}function t(b){var a=b.get("plugins"),d;e.each(a,function(b,f){"function"===typeof b&&(d=b,a[f]=new d)})}function j(b){var a,d=this.get("plugins");if(a=d.length)for(var c=0;c<a;c++)if(d[c][b])d[c][b](this)}var p=q("attribute"),k=e.ucfirst,i="_onSet",o=e.noop,l=p.extend({constructor:function(){this.callSuper.apply(this,arguments);var b=this.get("listeners"),
a;for(a in b)this.on(a,b[a]);this.initializer();t(this);j.call(this,"pluginInitializer");this.bindInternal();this.syncInternal()},initializer:o,__getHook:h,__callPluginsMethod:j,bindInternal:function(){var b=this.getAttrs(),a,d;for(a in b)if(d=i+k(a),this[d])this.on("after"+k(a)+"Change",s)},syncInternal:function(){var b=[],a;a=this.constructor;for(var d=this.getAttrs();a;)b.push(a),a=a.superclass&&a.superclass.constructor;b.reverse();for(a=0;a<b.length;a++){var c=b[a].ATTRS||{},f;for(f in c)if(f in
d){var e,g;(g=this[i+k(f)])&&0!==d[f].sync&&void 0!==(e=this.get(f))&&g.call(this,e)}}},plug:function(b){"function"===typeof b&&(b=new b);b.pluginInitializer&&b.pluginInitializer(this);this.get("plugins").push(b);return this},unplug:function(b){var a=[],d=this,c="string"===typeof b;e.each(d.get("plugins"),function(f){var e=0,g;b&&(c?(g=f.get&&f.get("pluginId")||f.pluginId,g!==b&&(a.push(f),e=1)):f!==b&&(a.push(f),e=1));e||f.pluginDestructor(d)});d.setInternal("plugins",a);return d},getPlugin:function(b){var a=
null;e.each(this.get("plugins"),function(d){if((d.get&&d.get("pluginId")||d.pluginId)===b)return a=d,!1});return a},destructor:e.noop,destroy:function(){this.get("destroyed")||(j.call(this,"pluginDestructor"),this.destructor(),this.set("destroyed",!0),this.fire("destroy"),this.detach())}});e.mix(l,{__hooks__:{initializer:h(),destructor:h("__destructor",!0)},ATTRS:{plugins:{value:[]},destroyed:{value:!1},listeners:{value:[]}},extend:function a(d,c,f){e.isArray(d)||(f=c,c=d,d=[]);f=f||{};c=c||{};c=
p.extend.call(this,c,f);c.__extensions__=d;n.call(c,{});if(d.length){var h={},g={};e.each(d.concat(c),function(a){if(a){e.each(a.ATTRS,function(a,c){var d=h[c]=h[c]||{};e.mix(d,a)});var a=a.prototype,c;for(c in a)a.hasOwnProperty(c)&&(g[c]=a[c])}});c.ATTRS=h;g.constructor=c;e.augment(c,g)}c.extend=f.extend||a;c.addMembers=n;return c}});var r=l.addMembers;return e.Base=l});
